from typing import final

# from server.apps.blogs.infrastructure.forms import SimpleScoreForm
from server.apps.blogs.logic.posts import commands
from server.apps.blogs.models import BlogPost


@final
# class Failed(Exception):
#     """
#     This is a domain error.
#
#     It means, that we are not able to rate this post.
#     Details are stored in the ``.context`` property.
#     """
#
#     def __init__(self, instance: BlogPost, form: SimpleScoreForm) -> None:
#         super().__init__()
#         self.context = {'form': form, 'instance': instance}
#
#
# def run(
#     instance: BlogPost,
#     form: SimpleScoreForm,
# ) -> None:
#     """Updates score of an existing post."""
#     score = form.get_valid_score()
#     if score is None:
#         raise Failed(instance, form)
#     commands.update_score(instance.id, score)
